<?php
require_once __DIR__."/bt_lexical_component.php";
require_once __DIR__."/bt_tokenizer.php";
require_once __DIR__."/bt_sintactic_component.php";
require_once __DIR__."/bt_parser.php";

class Brenda_Template {

	private $state = false;
	
	private $tokenizer;
	
	private $parser;
	
	private $lasted_error = null;
	
	public function __construct($document,$variables = null){
		
		$this->tokenizer = new \brenda_template\Tokenizer();
		
		$this->parser = new \brenda_template\Parser();
		
		$this->state = $this->tokenizer->init($document);
		
		$this->lasted_error = $this->tokenizer->lasted_error();
		
		if($this->state){
			
			$this->state = $this->parser->init($this->tokenizer->get_tokens_info());
			
			$this->lasted_error = $this->parser->lasted_error();
		}
	}
	
	public function get_state(){
		
		return $this->state;
	}
	
	public function get_blocks_info(){
	
		return $this->tokenizer->get_blocks_info();
	}
	
	public function get_tokens_info(){
	
		return $this->tokenizer->get_tokens_info();
	
	}
	public function get_lasted_error(){
		
		return var_export($this->lasted_error,true);
	}
}
?>